package com.future.cb.common.bean;

import org.springframework.http.HttpStatus;

import lombok.Data;

@Data
public class Result {
	private int code = 200;
	private Object result;
	private String errorMessage = "";

	public static Result ok(Object ret) {
		Result result = new Result();
		result.setResult(ret);
		return result;
	}
	/**
	 * 内部错误
	 * 
	 * @param message
	 * @return
	 */
	public static Result Error500(String message) {
		return error(message, HttpStatus.INTERNAL_SERVER_ERROR.value());
	}

	/**
	 * 认证失败
	 * 
	 * @param message
	 * @return
	 */
	public static Result Error401(String message) {
		return error(message,HttpStatus.UNAUTHORIZED.value());
	}

	
	/**
	 * 返回错误信息
	 * @param message
	 * @param httpcode
	 * @return
	 */
	public static Result error(String message,int httpcode) {
		Result result = new Result();
		result.setResult(null);
		result.setCode(httpcode);
		result.setErrorMessage(message);
		return result;
	}
}
